/**
 * 
 */
package smallChanges.statements;

import java.util.List;

import smallChanges.Tokenization.TokenSet;

/**
 * do-while loops are sort of backwards; first there is a single statement
 * for the "do" token, then there is the loop body, then the "header" statement
 * (a WhileStatementHeader).  So the "header" actually follows the body.
 * @author jspacco
 *
 */
public class DoStatement extends CompoundStatement
{
    // Just the do token that starts out a do-while loop
    private SingleStatement doStatement;
    
    public DoStatement(TokenSet tokenSet) {
        super(tokenSet);
    }
    
    /* (non-Javadoc)
     * @see smallChanges.statements.CompoundStatement#flattenHelper(java.util.List)
     */
    @Override
    List<Statement> flattenHelper(List<Statement> list)
    {
        list.add(doStatement);
        list=getBody().flattenHelper(list);
        list=getHeaderStmt().flattenHelper(list);
        return list;
    }

    @Override
    String toStringHelper(int depth)
    {
        return makePadding(depth) +getDoStatement().getImage()+
        " (coords " +getCoords()+ ") "+
        " with " + getBody().size()+
        " stmts\n" +
        getBody().toStringHelper(depth) +
        getHeaderStmt().toStringHelper(depth);
        //makePadding(depth)+getHeaderStmt().getImage();
    }
    
    
    /**
     * @return the doStatement
     */
    public SingleStatement getDoStatement()
    {
        return doStatement;
    }

    /**
     * @param doStatement the doStatement to set
     */
    public void setDoStatement(SingleStatement doStatement)
    {
        this.doStatement = doStatement;
    }

}
